package com.cloudbroker.openapi.manage.controller;

import com.cloudbroker.bcs.common.configure.ConfigUtil;
import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.IPUtil;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.base.vo.UserVO;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.customer.back.CustomerInfoBack;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.customer.vo.CustomerAliasForm;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.customer.vo.CustomerAvatarForm;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.customer.vo.CustomerInfoForm;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.leader.back.LeaderBackVo;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.leader.vo.LeaderGetMessageForm;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.user.back.*;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.user.vo.*;
import com.cloudbroker.bcs.platform.ltb.bizapi.t2service.business.UserT2BizService;
import com.cloudbroker.bcs.platform.ltb.common.ext.annotation.SaveLog;
import com.hundsun.jresplus.remoting.impl.annotation.ServiceParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;

import static com.cloudbroker.bcs.platform.ltb.common.util.RequestUtil.getSingleParameterMapForBody;

/**
 * Created by tianrui on 2016/7/8.
 */

@Controller
public class UserController {

    @Resource
    private UserT2BizService userT2BizService;

    /**
     * 短信验证码发送
     * */
    @ResponseBody
    @RequestMapping("/checkcode_get")
    @SaveLog(remark = "验证码发送")
    public SendSMSBack SMSCodeSend(HttpServletRequest request, String jsonpcallback){
        SendSMSForm form = getSingleParameterMapForBody(request , SendSMSForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcSMSCodeSend(form), jsonpcallback);
    }

    /**
     * 用户登录
     * */
    @ResponseBody
    @RequestMapping("/user_login")
    @SaveLog(remark = "用户登录")
    public UserLoginBack UserLogin(HttpServletRequest request, String jsonpcallback){
        UserLoginForm form = getSingleParameterMapForBody(request , UserLoginForm.class);
        form.setIp(IPUtil.getIpAddress(request));
        return VOUtil.setJsonpResult(userT2BizService.funcUserLogin(form), jsonpcallback);
    }

    /**
     * 用户登录
     * */
    @ResponseBody
    @RequestMapping("/user_open_app")
    @SaveLog(remark = "用户打开APP")
    public HSBCPSBackVO func_open_app(HttpServletRequest request, String jsonpcallback){
        UserOpenAppForm form = getSingleParameterMapForBody(request , UserOpenAppForm.class);
        return VOUtil.setJsonpResult(userT2BizService.func_user_open_app(form), jsonpcallback);
    }

    /**
     * 用户密码重置
     * */
    @ResponseBody
    @RequestMapping("/user_pwd_reset")
    @SaveLog(remark = "用户密码重置")
    public HSBCPSBackVO UserPasswordRest(HttpServletRequest request, String jsonpcallback){
        UserPasswordRestForm form = getSingleParameterMapForBody(request , UserPasswordRestForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcUserPasswordRest(form), jsonpcallback);
    }


    /**
     * 用户登出
     * */
    @ResponseBody
    @RequestMapping("/user_logout")
    @SaveLog(remark = "用户登出")
    public HSBCPSBackVO UserLogOut(HttpServletRequest request, String jsonpcallback){
        UserLogoutForm form = getSingleParameterMapForBody(request , UserLogoutForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcUserLogOut(form), jsonpcallback);
    }


    /**
     * 用户密码修改
     * */
    @ResponseBody
    @RequestMapping("/user_pwd_mod")
    @SaveLog(remark = "用户密码修改")
    public HSBCPSBackVO UserPasswordUpdate(HttpServletRequest request, String jsonpcallback){
        UserPasswordUpdateForm form = getSingleParameterMapForBody(request , UserPasswordUpdateForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcUserPasswordUpdate(form), jsonpcallback);
    }


    /**
     * 用户昵称像修改
     * */
    @ResponseBody
    @RequestMapping("/user_alias_mod")
    @SaveLog(remark = "用户昵称修改")
    public HSBCPSBackVO UserAliasUpdate(HttpServletRequest request, String jsonpcallback){
        UserAliasNameForm form = getSingleParameterMapForBody(request , UserAliasNameForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcUserAliasNameUpdate(form), jsonpcallback);
    }

    /**
     * 用户头像修改
     * */
    @ResponseBody
    @RequestMapping("/user_headpic_mod")
    @SaveLog(remark = "用户头像修改")
    public HSBCPSBackVO UserHeadpicUpdate(HttpServletRequest request, String jsonpcallback){
        UserAvatarForm form = getSingleParameterMapForBody(request , UserAvatarForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcUserHeadpicUpdate(form), jsonpcallback);
    }

    /**
     * 用户个人信息获取
     * */
    @ResponseBody
    @RequestMapping("/user_infomation_qry")
    @SaveLog(remark = "用户个人信息获取")
    public UserInfoBack UserInfoQuery(HttpServletRequest request, String jsonpcallback){
        UserInfoQryForm form = getSingleParameterMapForBody(request , UserInfoQryForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcUserInfoQuery(form), jsonpcallback);
    }

    /**
     * 游客身份获取
     * */
    @ResponseBody
    @RequestMapping("/visitor_login")
    @SaveLog(remark = "游客身份登录")
    public UserLoginBack VisitorLogin(HttpServletRequest request, String jsonpcallback){
        VisitorLoginForm form = getSingleParameterMapForBody(request , VisitorLoginForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcVisitorLogin(form), jsonpcallback);
    }


    @ResponseBody
    @RequestMapping("/authorization_login")
    @SaveLog(remark = "第三方登录授权")
    public UserLoginBack LoginAuthorization(HttpServletRequest request, String jsonpcallback) {
        LoginAuthorizationForm form  = getSingleParameterMapForBody(request,LoginAuthorizationForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcLoginAthorization(form), jsonpcallback);

    }

    @ResponseBody
    @RequestMapping("/redirectLogin")
    @SaveLog(remark = "其它云纪app账户登录")
    public UserLoginBack redirectLogin(HttpServletRequest request, String jsonpcallback) {
        RedirectLoginForm form  = getSingleParameterMapForBody(request,RedirectLoginForm.class);
        return VOUtil.setJsonpResult(userT2BizService.redirectLogin(form), jsonpcallback);

    }


    @ResponseBody
    @RequestMapping("/xinanLogin")
    @SaveLog(remark = "西南账户登录")
    public UserLoginBack XiNanLogin(HttpServletRequest request, String jsonpcallback) {
        XiNanUserLoginForm form  = getSingleParameterMapForBody(request,XiNanUserLoginForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcXiNanLogin(form), jsonpcallback);

    }

    @ResponseBody
    @RequestMapping("/invite_info")
    @SaveLog(remark = "获取用户邀请码信息")
    public InviteInfoBack func_get_invite_info(HttpServletRequest request, String jsonpcallback) {
        InviteinfoForm form  = getSingleParameterMapForBody(request,InviteinfoForm.class);
        return VOUtil.setJsonpResult(userT2BizService.func_get_invite_info(form), jsonpcallback);

    }


    @ResponseBody
    @RequestMapping("/rongyun_token")
    @SaveLog(remark = "获取融云token")
    public RongYunTokenBack funcRongyunToken(HttpServletRequest request, String jsonpcallback) {
        RongYunTokenQueryForm form  = getSingleParameterMapForBody(request,RongYunTokenQueryForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcRongyunToken(form), jsonpcallback);

    }

    @ResponseBody
    @RequestMapping("/user_basic_info_list_qry")
    @SaveLog(remark = "获取用户列表基本信息")
    public UserBasicInfoList funcUserBasicInfoListQry(HttpServletRequest request, String jsonpcallback) {
        UserBasicInfoListQryForm form  = getSingleParameterMapForBody(request,UserBasicInfoListQryForm.class);
        return VOUtil.setJsonpResult(userT2BizService.funcUserBasicInfoListQry(form), jsonpcallback);

    }
}
